package chapter06.Example03;

import java.util.ArrayList;
import java.util.Iterator;

public class Example03 {
    public static void main(String[] args) {
        // 迭代器 Iterator 遍历集合
        ArrayList list = new ArrayList();
        list.add("罗翔");
        list.add("马庆");
        list.add("爱玩");
        list.add("原神");
        Iterator it = list.listIterator();// 返回一个list对象的迭代器
        while (it.hasNext()){
            Object obj = it.next();
            System.out.println(obj);
        }
        System.out.println("for循环迭代集合");

        for (Object obj:list){
            System.out.println(obj);
        }
    }
}
